package net.ch2.pc12.tech.ackborn.model;

import java.util.List;

import net.ch2.pc12.tech.ackborn.dao.CacheDAO;
import net.ch2.pc12.tech.ackborn.dao.SourceDAO;
import android.content.Context;

public class BbsThreadModel {

	private String boardId;
	
	private String threadId;
	
	private String threadName;
	
	private String datName;
	
	private int count;
	
	private int readCount;
	
	private int priority;

	private String boardUrl;
	
	private List<BbsArticleModel> list;
	
	public boolean hasCache(Context context){
		CacheDAO cdao = new CacheDAO(context);
		return cdao.hasThreadCache(boardId,threadId);
	}
	
	
	public String getBoardUrl() {
		return boardUrl;
	}

	public void setBoardUrl(String boardUrl) {
		this.boardUrl = boardUrl;
	}

	public String getBoardId() {
		return boardId;
	}

	public void setBoardId(String boardId) {
		this.boardId = boardId;
	}

	public String getThreadId() {
		return threadId;
	}

	public void setThreadId(String threadId) {
		this.threadId = threadId;
	}

	public String getThreadName() {
		return threadName;
	}

	public void setThreadName(String threadName) {
		this.threadName = threadName;
	}

	public String getDatName() {
		return datName;
	}

	public void setDatName(String datName) {
		this.datName = datName;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getReadCount() {
		return readCount;
	}

	public void setReadCount(int readCount) {
		this.readCount = readCount;
	}

	public int getPriority() {
		return priority;
	}

	public void setPriority(int priority) {
		this.priority = priority;
	}
	
	public int getNotReadCount(){
		return (count - readCount);
	}


	public List<BbsArticleModel> getArticleModelList() {
		return list;
	}
	
	public void load(boolean reload, Context listener) {
		CacheDAO cdao = new CacheDAO(listener);
		
		if(reload){
			SourceDAO sdao = new SourceDAO(listener);
			list = sdao.getArticleModelList(this);
			cdao.storeBbsArticleModelList(list,this);
		}else{
			list = cdao.getBbsArticleModelList(this);
		}
	}	
}
